<template>
	<view class="main">
		<view class="content">
			<!-- #ifdef MP-WEIXIN -->
			<view class="userinfo u-flex-between">
				<view class="userInfo-left u-flex" @click.stop="infoClick">
					<u-avatar :src="isLogin?userInfo.avatar:$getSystemConfig('platform_logo_img')"
						size="100rpx"></u-avatar>
					<view class="userinfo-content">
						<view class="userinfo-top u-flex">
							<view class="userinfo-data">
								<view class="nickname" v-if="isLogin">{{userInfo.nickname}}</view>
								<view class="no-nickname" v-else>登录/注册</view>
							</view>
							<view class="userinfo-grade"
								@click.stop="$navigateTo('/subPackages/member/index?current='+userInfo.members_grade)"
								v-if="isLogin && userInfo.members">
								<u-image :src="`${userInfo.members.icon}`" :showMenuByLongpress="false" width="92rpx"
									height="36rpx"></u-image>
							</view>
						</view>
						<view class="create-time" v-if="isLogin && userInfo.userGrade">等级：{{userInfo.userGrade.name}}
						</view>
						<view class="create-time u-flex" v-if="isLogin && userInfo"
							@click.stop="$copyText(userInfo.id)">
							ID：{{userInfo.id}}<u-icon name="file-text" color="#9e9e9e" size="16">
							</u-icon>
						</view>
					</view>
				</view>
				<view class="userinfo-right u-flex-end">
					<view class="right-li" @click.stop="$navigateTo('/subPackages/user/setUp')">
						<image class="image" :src="$getImageUrl('/user_client/static/icons/shezhi.svg')" />
					</view>
					<view class="right-li" @click.stop="$navigateTo('/subPackages/message/index')">
						<image class="image" :src="$getImageUrl('/user_client/static/icons/message.png')" />
						<view class="subscript"
							v-if="userInfo && Object.keys(userInfo).length > 0 && userInfo.message_noreal_total != 0">
							{{userInfo.message_noreal_total < 100?userInfo.message_noreal_total:'99+'}}
						</view>
					</view>
				</view>
			</view>
			<!-- 			<view v-if="isLogin">
				{{userInfo.id==1?'institution_id：'+institution_id+'；institution_agent_id'+institution_agent_id:''}}
			</view> -->
			<!-- #endif -->
			<!-- #ifdef H5||APP-PLUS -->
			<!-- <view class="userinfo u-flex" @click="isLogin || $getCache('user_type') != 2?$navigateTo('/subPackages/userInfo/index'):''">
				<u-avatar :src="isLogin?userInfo.avatar:$getSystemConfig('platform_logo_img')" size="100rpx"></u-avatar>
				<view class="userinfo-content">
					<view class="userinfo-data">
						<view class="nickname" v-if="isLogin">{{userInfo.nickname}}</view>
						<view class="no-nickname" @tap="$navigateTo('/subPackages/login/wxAuth')" v-else>登录/注册</view>
					</view>
				</view>
			</view> -->
			<!-- #endif -->
		</view>
		<view class="money u-flex">
			<view class="li u-flex-column u-flex-center" @click="$navigateTo('/subPackages/balance/index')">
				<view class="li-number">{{isLogin?userInfo.fund.amount:'0'}}</view>
				<view class="li-text u-flex-center">
					<view class="text">余额</view>
				</view>
			</view>
			<view class="li u-flex-column u-flex-center" @click="$navigateTo('/subPackages/user/integral-record')">
				<view class="li-number">{{isLogin?userInfo.integral:'0'}}</view>
				<view class="li-text u-flex-center">
					<view class="text">积分</view>
				</view>
			</view>
			<view class="li u-flex-column u-flex-center" @click="$navigateTo('/subPackages/user/coupon-record')">
				<view class="li-number">{{isLogin?userInfo.coupon_count:'0'}}</view>
				<view class="li-text u-flex-center">
					<view class="text">优惠券</view>
				</view>
			</view>
			<!-- <view class="li u-flex-column u-flex-center"
				@click="$navigateTo('/subPackages/user/integral-product-certificate')">
				<view class="li-number">{{isLogin?userInfo.integral_certificate_count:'0'}}</view>
				<view class="li-text u-flex-center">
					<view class="text">积分商品券</view>
				</view>
			</view> -->
			<view class="li u-flex-column u-flex-center" @click="$navigateTo('/subPackages/user/collection')">
				<view class="li-number">{{isLogin?userInfo.collection_count:'0'}}</view>
				<view class="li-text u-flex-center">
					<view class="text">我的收藏</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: "navbar",
		data() {
			return {
				institution_id: 0,
				institution_agent_id: 0
			};
		},
		// 此处定义传入的参数
		props: {},
		computed: {
			// 获取消息总数
			...mapState('user', ['userInfo', 'isLogin'])
		},
		mounted() {
			this.institution_id = uni.getStorageSync('institution_id') || '';
			this.institution_agent_id = uni.getStorageSync('institution_agent_id') || '';
		},
		methods: {
			infoClick() {
				console.log(this.isLogin)
				console.log(this.userInfo)
				this.isLogin ? this.$navigateTo('/subPackages/userInfo/index') : this.$navigateTo(
					'/subPackages/login/wxAuth')
			}
		}
	}
</script>
<style lang="scss" scoped>
	.main {
		width: 100%;
		padding: 90px 48rpx 20rpx;
		background-color: #FFFFFF;
		box-sizing: border-box;

		.content {
			height: 134rpx;

			.userinfo-content {
				padding-left: 30rpx;

				.userinfo-top {

					.userinfo-data {
						line-height: 1;
						font-size: 30rpx;
						font-weight: bold;
					}

					.userinfo-grade {
						padding-left: 20rpx;
					}
				}

				.create-time {
					padding-top: 16rpx;
					font-size: 24rpx;
					line-height: 1;
					color: #4c4c4c;
				}
			}
		}

		.userinfo-right {

			.right-li {
				position: relative;
				margin-right: 20rpx;

				.image {
					width: 46rpx;
					height: 46rpx;
					display: block;
				}

				.subscript {
					min-width: 28rpx;
					padding: 0 5rpx;
					height: 28rpx;
					line-height: 28rpx;
					position: absolute;
					top: -10px;
					right: -10px;
					border-radius: 100rpx;
					color: #FFFFFF;
					font-size: 18rpx;
					text-align: center;
					background-color: #CC242B;
					box-sizing: border-box;
				}
			}
		}
	}


	.money {
		width: 100%;
		/* #ifdef APP-PLUS || H5 */
		padding-top: 20rpx;
		/* #endif */

		.line {
			width: 2rpx;
			height: 20rpx;
			background-color: #e3e3e3;
		}

		.li {
			width: 25%;
			font-size: 22rpx;
			text-align: center;
			padding: 25rpx 0 30rpx;

			.li-number {
				line-height: 1;
				font-size: 24rpx;
				font-weight: bold;
			}

			.li-text {
				padding-top: 15rpx;
				line-height: 1;
				color: #4f4f4f;
				font-size: 22rpx;

				.text {
					padding-right: 6rpx;
				}
			}
		}
	}
</style>